# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libpeas

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.0
pkgrel=1
pkgdesc="A GObject-based plugins engine (mingw-w64)"
arch=('any')
url="http://www.gtk.org"
license=("GPL2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "${MINGW_PACKAGE_PREFIX}-gtk-doc"
            "intltool"
            "${MINGW_PACKAGE_PREFIX}-python3-gobject"
            "${MINGW_PACKAGE_PREFIX}-python2-gobject"
            "${MINGW_PACKAGE_PREFIX}-glade")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
        "${MINGW_PACKAGE_PREFIX}-gtk3"
        "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme"
        )
options=('strip' 'staticlibs')
install=${_realname}-${CARCH}.install
source=(http://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz
        0001-allow-shared-libs.patch
        0002-give-cc-to-gir-scanner.all.patch)
md5sums=('b388cdb1c38ac8701f85c8278df0de0a'
         '8b0ca87de555d4519de0ab856a825d84'
         'b79cae8a6794dc2511f6fcceaa809111')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-allow-shared-libs.patch
  patch -p1 -i ${srcdir}/0002-give-cc-to-gir-scanner.all.patch

  autoreconf -fi
}

build() {
    mkdir -p "${srcdir}/build-${MINGW_CHOST}"
    cd "${srcdir}/build-${MINGW_CHOST}"
    ${srcdir}/${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --sysconfdir=${MINGW_PREFIX}/etc \
      --localstatedir=${MINGW_PREFIX}/var \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --enable-static \
      --enable-shared \
      --enable-python2 \
      --enable-python3 \
      --enable-glade-catalog \
      --enable-gtk \
      DATADIRNAME=share
    
    # https://bugzilla.gnome.org/show_bug.cgi?id=655517
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make -j1 V=1
}

package() {
    cd "${srcdir}/build-${MINGW_CHOST}"
    make DESTDIR="$pkgdir" install
}
